package edu.hpu.mybatis02.service.impl;

import edu.hpu.mybatis02.mapper.MallUserMapper;
import edu.hpu.mybatis02.pojo.MallUser;
import edu.hpu.mybatis02.pojo.MallUserRegisterParam;
import edu.hpu.mybatis02.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 业务层的实现类
 */
@Service
//springboot会创建对象，对象放在容器中
public class UserServiceImp implements UserService {

    //调用数据访问层
    @Autowired
            //从容器中取对象，赋值给mallUserMapper
    MallUserMapper mallUserMapper;
    @Override
    public boolean register(MallUserRegisterParam mallUserRegisterParam) {
        //判断用户名是否存在
        MallUser mallUser = mallUserMapper.selectByUsername(mallUserRegisterParam.getUsername());
        if (mallUser==null){
            //如查不存在，保存用户信息
            return true;
        }else{
            //如果存在返回false
            return false;
        }

    }
}
